﻿package frEngine.shader.filters.fragmentFilters
{
    import baseEngine.core.*;
    import com.gengine.resource.*;
    import frEngine.manager.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;

    public class Scale9FragmentFilter extends FragmentFilter
    {
        public var texture:Texture3D;

        public function Scale9FragmentFilter(param1:Texture3D)
        {
            super([param1]);
            this.texture = param1;
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{texture1}", false).value = this.texture;
            return;
        }// end function

        override public function get programeId() : String
        {
            if (this.texture && (this.texture.loadedAndUpload || this.texture.targetInfo))
            {
                return "Scale9FragmentFilter:" + FilterBase.ATLFormat[this.texture.format] + ",mip:" + this.texture.mipMode;
            }
            return null;
        }// end function

        override public function clone() : FilterBase
        {
            var _loc_1:* = Resource3dManager.instance.getTexture3d(this.texture.request, this.texture.mipMode);
            var _loc_2:* = new TextureFilter(_loc_1);
            return _loc_2;
        }// end function

        override public function createFragmentUvCoord(param1:Program3dRegisterInstance) : String
        {
            var _loc_2:* = new Array();
            var _loc_3:String = "";
            _loc_2.push(new ToBuilderInfo("ft0", FilterName.F_UVPostion, false, 1));
            _loc_3 = _loc_3 + "mov           ft0         \t {V_UvOriginalPos}        \t\t\t\t\n";
            _loc_3 = param1.toBuild(_loc_3, _loc_2);
            return _loc_3;
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("fs0", "{texture1}", false, 1, this.texture));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + ("tex        {output}           {F_UVPostion}.xy    " + getSmapleString("fs0", this.texture.format, param2, this.texture.mipMode) + "\t\n");
            if (this.texture.format == TextureFormat.FORMAT_COMPRESSED_ALPHA)
            {
                _loc_4 = _loc_4 + "mul\t\t\t{output}.xyz\t   {output}.xyz\t\t\t{output}.w\t \n";
            }
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            return _loc_4;
        }// end function

    }
}
